$(function()
{
	var curPic = 1;
	var maxPic = pia.length-2;
	var picHeight;
	$("#theCommentsDialog").draggable({handle:"#commentsHeader"});
	$.post("showPic.php", {snID : pia[curPic]}, function(data)
	{
		$("#picture").html(data);
	});
	$.post("showComments.php", {snID : pia[curPic]}, function(data)
	{
		$("#commentsDialog").html(data);
	});
	$("#prevPic").click(function()
	{
		if(curPic > 1)
		{
			curPic--;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
		else
		{
			curPic = maxPic;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
	});
	$("#nexPic").click(function()
	{
		if(curPic < maxPic)
		{
			curPic++;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
		else
		{
			curPic = 1;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
	});
	$("#pliosPictureDiv").click(function()
	{
		if(curPic < maxPic)
		{
			curPic++;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
		else
		{
			curPic = 1;
			$.post("showPic.php", {snID : pia[curPic]}, function(data)
			{
				$("#picture").html(data);
			});
			$.post("showComments.php", {snID : pia[curPic]}, function(data)
			{
				$("#commentsDialog").html(data);
			});
		}
	});
	$('#closeComments').click(function()
	{
		$('#theCommentsDialog').hide('explode');
	});
});
























